#ifndef __SERVER_REGISTERSENDER_H__
#define __SERVER_REGISTERSENDER_H__

#include "gwmessagemap.hpp"
#include "IMessageOperator.h"
#include "protonet.hpp"
#include "netlib.h"
#include "../GatewayServer.h"
#include "../../Sender/GatewayServerSender.h"

/**
*@file       GWServer_RegisterSender.h
*@brief      send message GWServer_Register
*
*@author     graywind
*@version    1.0.0.0
*@data       2012/3/23
*/

///message wrapper
class msgGWServer_Register
{
public:
    static const int MessageId = GWServer_Register;
    //TODO
    pnSessionHandle SessionId;
    ServerInfo      MsgContent;
    ///@brief     constructor
    ///param[in]  session_id    identifier of the session
    ///param[in]  server_ip     ip address of the server
    ///param[in]  server_port   port of the server
    ///param[in]  server_type   type of the server
    msgGWServer_Register(int session_id, const std::string& server_ip, int server_port, eServerType server_type):
    SessionId(session_id)
    {
        MsgContent.set_servertype(server_type);
        MsgContent.set_ipaddr(server_ip);
        MsgContent.set_port(server_port);
    }
};

class HandleGWServer_Register
{
public:
    ///@brief     handle message
    ///param[in]  msg     message wrapper of GWServer_Register
    ///retval     void
    static void HandleMessage(msgGWServer_Register* msg)
    {
        //TODO
        //Main Message:  msgGatewayServer
        msgGatewayServer mainMsg(msg->SessionId, msgGWServer_Register::MessageId, ProtoNet<ServerInfo>::IntoBytes(msg->MsgContent));
        gwMessagePort::ProcessMessage(&mainMsg);
    }
};
///[message wrapper]  [handler]
RegisterHandler(msgGWServer_Register, HandleGWServer_Register);

#endif
